package com.cskaoyan.mall.order.controller.chain;

import com.cskaoyan.mall.mq.constant.MqTopicConst;
import com.cskaoyan.mall.mq.producer.BaseProducer;
import com.cskaoyan.mall.order.query.OrderInfoParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @Author Pudding
 * @Date 2024/7/18 21:40
 * 4. 发送一个订单超时自动取消的消息
 */
@Component
public class SendMessageHandler extends AbstractHandler{

    @Autowired
    BaseProducer baseProducer;

    @Override
    public void handle(HandlerContext handlerContext) {

        //获取责任链上下文对象参数
        Long orderId = handlerContext.getOrderId();

        //4. 发送订单超时自动取消的消息
        //  1  2  3   4   5  6  7  8  9 10 11 12 13  14  15 16  17  18
        // 1s 5s 10s 30s 1m 2m 3m 4m 5m 6m 7m 8m 9m 10m 20m 30m 1h  2h
        baseProducer.sendDelayMessage(MqTopicConst.DELAY_ORDER_TOPIC, orderId,4);

        if (nextHandler != null) {
            nextHandler.handle(handlerContext);
        }
    }
}
